//
//  MBProgressHUD+Alert.m
//  EasyToTesco2.0
//
//  Created by 杨森 on 16/6/30.
//  Copyright © 2016年 EasyToTesco. All rights reserved.
//

#import "MBProgressHUD+Alert.h"

@implementation MBProgressHUD (Alert)

//正在加载数据
+ (instancetype)loadingInformationToView
{
    
   MBProgressHUD *hud = [[MBProgressHUD alloc] init];
   hud.mode =MBProgressHUDModeIndeterminate;
   hud.color = [UIColor clearColor];
   hud.activityIndicatorColor = DEFAULT_COLOR;
   hud.dimBackground = false;
   hud.removeFromSuperViewOnHide = YES;
   [hud show:YES];
   return hud;

    
}

+ (instancetype)showMessage:(NSString *)message toView:(UIView *)view dimBackground:(BOOL)staus AndCompleteBlock:(CompleteBlock)completeBlock
{
    MBProgressHUD *HUD = [[MBProgressHUD alloc] initWithView:view];
    [view addSubview:HUD];
    HUD.labelText = message;
    HUD.mode = MBProgressHUDModeText;
    HUD.dimBackground = staus;
    HUD.labelFont = FONT(14);
    HUD.minShowTime = 1.5;
    HUD.margin = 15;
    HUD.removeFromSuperViewOnHide = YES;
//    __weak typeof(HUD) weakSelf = self;
    [HUD showAnimated:YES whileExecutingBlock:^{
//        sleep(1.0);
    } completionBlock:^{
        [HUD removeFromSuperview];
        __block HUD = nil;
        
        if (completeBlock) {
            completeBlock(completeBlock);
        }
    }];
        
    return HUD;
}

+ (instancetype)show:(UIView *)view andMessage:(NSString *)text {
    MBProgressHUD *hud = [[MBProgressHUD alloc] init];
    [hud show:YES];
    hud.labelFont = FONT(13);
//    hud.minShowTime = 1.0;
    hud.margin = 15;
    hud.removeFromSuperViewOnHide = YES;
    hud.labelText = text;
    [view addSubview:hud];
    return hud;
}

@end
